<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Month')}:</label>
        <div class="col-xs-12 col-sm-8">
                <input id="c-month" onchange="onblur(this)" class="form-control datetimepicker" data-date-format="YYYY-mm" data-use-current="true" name="row[month]" type="text" value="{:date('Y-m')}">
                <div style="height: 30px;width:40px;background: #337ab7;color: white" onclick="getDate()"> 获取</div>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Date')}:</label>
        <div class="col-xs-12 col-sm-8" id="date-div">
            <?php foreach($date_list as $k=>$val): ?>
            <div class="input-group">
                <span class="input-group-addon">日期： </span>
                <input type="text" readonly="readonly" name="row[<?=$val?>][date]" value="<?=$val;?>" class="form-control">
                <span class="input-group-addon"> 奖励：</span>
                <select class="form-control" name="row[<?=$val?>][reward]">
                    <?php foreach($data_list as $k1=>$val1): ?>
                        <option value="<?=$k1?>"><?=$val1?></option>
                    <?php endforeach; ?>
                </select>
                <span class="input-group-addon">数量：</span>
                <input   name="row[<?=$val?>][num]" type="number" min="1" value="1" class="form-control">
            </div>
            <p />
            <?php endforeach; ?>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Reward')}:</label>
        <div class="col-xs-12 col-sm-8" id="div-content">
            <div onclick="jia()" id="jia-div" style="cursor:pointer;height: 30px;width:40px;background: #337ab7;line-height: 30px;color:white;text-align: center;border-radius:5px; "> + </div>
            <div class="input-group">
                <span class="input-group-addon">累计签到： </span>
                <input type="number" name="row[date_num][]"  value="3" class="form-control">
                <span class="input-group-addon"> 天 奖励：</span>
                <select class="form-control" name="row[reward][]">
                    <?php foreach($data_list as $k1=>$val1): ?>
                        <option value="<?=$k1?>"><?=$val1?></option>
                    <?php endforeach; ?>
                </select>
                <span class="input-group-addon">数量：</span>
                <input   name="row[num][]" type="number" min="1" value="1" class="form-control">
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="radio">
            {foreach name="statusList" item="vo"}
            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label>
            {/foreach}
            </div>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

<script>
    function jia() {
        console.log(111);
        var html =`
        <div class="input-group">
                <span class="input-group-addon">连续签到： </span>
                <input type="number" name="row[date_num][]"  value="3" class="form-control">
                <span class="input-group-addon"> 天 奖励：</span>
                <select class="form-control" name="row[reward][]">
                    <?php foreach($data_list as $k1=>$val1): ?>
                        <option value="<?=$k1?>"><?=$val1?></option>
                    <?php endforeach; ?>
                </select>
                <span class="input-group-addon">数量：</span>
                <input   name="row[num][]" type="number" min="1" value="1" class="form-control">
                <span onclick="jian(this)" title="删除" class="input-group-addon" style="background: #777;color: white; cursor:pointer;">-</span>
            </div>
        `;
        $("#div-content").append(html);
    }

    function jian(obj) {
        $(obj).parent().remove();
    }

    function getDate(obj) {
        var month = $("#c-month").val();
        console.log(month);
        if(month){
            $.post("sign/getDate", {month:month}, function (tem) {
                console.log(tem);
                $("#date-div").html(tem);
            }, 'html')
        }

    }

</script>
